<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/struct_info.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/js/web/struct_info.js?1.0"></script>
<script>
$(function(){
	$("#sex").val("${userInfo.sex}");
	$("#nation").val("${userInfo.nation}");
	$("#marriage").val("${userInfo.marriage}");
	$("#education").val("${userInfo.education}");
	
	$('#keyname').on('click',function(){
		var keyname = $("#keyname").val();
		$.post("${contextPath}/index/getDepartment.json", {
			"keyname" : keyname
		}, function(ms) {
			var list = ms.departmentList;
			var objHtml = "";
			for(var i=0;i<list.length;i++){
				objHtml += '<option value="'+list[i].keyname+'">'+list[i].name+'</option>'
			}
			$("#department").html(objHtml);
		});
	});
	
});

	var updateInfo = function(){
		var nickname = $("#nickname").val();
		var department = $("#department").val();
		var sex = $("#sex").val();
		var nation = $("#nation").val();
		var marriage = $("#marriage").val();
		var region = $("#region").val();
		var idnum = $("#idnum").val();
		var workexp = $("#workexp").val();
		var birthday = $("#birthday").val();
		var entryday = $("#entryday").val();
		var hometown = $("#hometown").val();
		var census = $("#census").val();
		var address = $("#address").val();
		var phone = $("#phone").val();
		var email = $("#email").val();
		var contact = $("#contact").val();
		var contact_phone = $("#contact_phone").val();
		var education = $("#education").val();
		var certificate = $("#certificate").val();
		
		$.post("${contextPath}/index/updateInfo.json", {
			"nickname" : nickname,
			"department" : department,
			"sex" : sex,
			"nation" : nation,
			"marriage" : marriage,
			"region" : region,
			"idnum" : idnum,
			"workexp" : workexp,
			"birthday" : birthday,
			"entryday" : entryday,
			"hometown" : hometown,
			"census" : census,
			"address" : address,
			"phone" : phone,
			"email" : email,
			"contact" : contact,
			"contact_phone" : contact_phone,
			"education" : education,
			"certificate" : certificate
		}, function(ms) {
			if(ms.flag==true){
				alert("修改成功");
			}else{
				alert("服务器繁忙");
			}
		});
	}

</script>
</head>

<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>组织架构</li>
			<li>&gt;</li>
			<li class="current">我的资料信息</li>
		</ul>
	</div>
	<div id="caption">
		<ul>
			<li><span class="title">操作提示：</span></li>
			<li>Ctrl+Enter 提交</li>
		</ul>
	</div>
	<div id="container">
		<div id="title"></div>
		<table id="infotable">
			<tr class="fields">
				<th colspan="2">基本信息<span id="modydate" class="caption">（最后修改于2016-6-6）</span></th>
			</tr>
			<tr>
				<th width="25%">姓名
					<p class="caption">姓名和职位只有管理员才能修改</p>
				</th>
				<td width="75%">
					<div class="left avatar">
						<img id="photo" src="${staticServer}/img/avatar/0.png" width="80" height="80" />
					</div>
					<div class="left">
					<#if webutil.getCookieUser().usergroup!="0">
						<h2>${userInfo.nickname}</h2>
						<h4>${userInfo.departments}（${userInfo.job}）</h4>
					<#else>
						<input id="nickname" value="${userInfo.nickname}" /><br /> 
						<select id="keyname">
							<#if departmentList??>
							<#list departmentList as list>
								<option value="${list.keyname}">${list.name}</option>
							</#list>
							</#if>
						</select> 
						<select id="department">
							<option value="${department}">${departmentName}</option>
						</select><br /> 
					</#if>
						<select id="sex">
							<option>男</option>
							<option>女</option>
						</select> 
					
						<select id="nation">
							<option>汉族</option>
							<option>壮族</option>
							<option>满族</option>
							<option>回族</option>
							<option>苗族</option>
							<option>彝族</option>
							<option>藏族</option>
							<option>维吾尔族</option>
							<option>土家族</option>
							<option>蒙古族</option>
							<option>其他少数民族</option>
						</select> 
						
						<select id="marriage">
							<option>未婚</option>
							<option>已婚</option>
							<option>离异</option>
						</select>
				</div>
				</td>
			</tr>
			<tr>
				<th>办公地址</th>
				<td>
				<select id="region">
					<#if office_List??>
					<#list office_List as list>
						<#if list.name==userInfo.regions>
							<option value="${list.keyname}" selected="selected">${list.name}</option>
						<#else>
							<option value="${list.keyname}" >${list.name}</option>
						</#if>
					</#list>
					</#if>
				</select>
				</td>
			</tr>
			<tr>
				<th>身份证号码</th>
				<td><input id="idnum" type="text" value="${userInfo.idnum}" size="50" maxlength="20" /></td>
			</tr>
			<tr>
				<th>工作年限</th>
				<td><input id="workexp" type="text" value="${userInfo.workexp}" size="2" maxlength="2" /> 年</td>
			</tr>
			<tr>
				<th>出生日期</th>
				<td><input type="text" readyonly="true" id="birthday" value="${userInfo.birthdays}" size="15"
					maxlength="15" /> <em class="caption">点击弹出日期选择框顶部可切换月、日、年选择界面</em></td>
			</tr>
			<tr>
				<th>入职日期</th>
				<td><input type="text" readyonly="true" id="entryday" value="${userInfo.entrydays}" size="15"
					maxlength="15" /> <em class="caption">点击弹出日期选择框顶部可切换月、日、年选择界面</em></td>
			</tr>
			<tr class="fields">
				<th colspan="2">联系信息</th>
			</tr>
			<tr>
				<th>籍贯</th>
				<td><input id="hometown" type="text" value="${userInfo.hometown}" size="15" maxlength="10" /></td>
			</tr>
			<tr>
				<th>户籍地址</th>
				<td><input id="census" type="text" value="${userInfo.census}" size="50" maxlength="100" /></td>
			</tr>
			<tr>
				<th>现居地址</th>
				<td><input id="address" type="text" value="${userInfo.address}" size="50" maxlength="100" /></td>
			</tr>
			<tr>
				<th>手机号码</th>
				<td><input id="phone" type="text" value="${userInfo.phone}" size="15" maxlength="15" /></td>
			</tr>
			<tr>
				<th>电子邮箱</th>
				<td><input id="email" type="text" value="${userInfo.email}" size="50" maxlength="100" /></td>
			</tr>
			<tr class="fields">
				<th colspan="2">紧急联系人</th>
			</tr>
			<tr>
				<th>姓名</th>
				<td><input id="contact" type="text" value="${userInfo.contact}" size="50" maxlength="50" /></td>
			</tr>
			<tr>
				<th>电话号码</th>
				<td><input id="contact_phone" type="text" value="${userInfo.contact_phone}" size="15" maxlength="15" /></td>
			</tr>
			<tr class="fields">
				<th colspan="2">学历信息</th>
			</tr>
			<tr>
				<th>最高学历</th>
				<td><select id="education">
						<option value="博士">博士</option>
						<option value="研究生">研究生</option>
						<option value="本科">本科</option>
						<option value="大专">大专</option>
						<option value="中专">中专</option>
						<option value="初中">初中</option>
				</select></td>
			</tr>
			<tr>
				<th>职称或证书</th>
				<td><input id="certificate" type="text" value="${userInfo.certificate}" size="50" maxlength="100" /></td>
			</tr>
		</table>
		<div id="controlbar">
			<input type="button" class="submit" onclick="updateInfo()" value="  保存所有修改的内容  " />
		</div>
	</div>
	<div id="__SEL_AVATAR">
		<ul style="overflow: auto;">
	</ul>
	</div>
</body>
</html>